//
//  PushOutViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/29.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "PushOutViewController.h"
#import "PushOutBottomView.h"

@interface PushOutViewController ()


@property (nonatomic, strong)PushOutBottomView * pushView;

@property (nonatomic, weak)UIImageView * backImageView;

@property (nonatomic, weak)UILabel * oneShowLabel;

@property (nonatomic, weak)UILabel * inviteNumLabel;

@property (nonatomic, weak)UILabel * numberLabel;

@property (nonatomic, weak)UILabel * explationOneLabel;

@property (nonatomic, weak)UIView * oneLineView;

@property (nonatomic, weak)UILabel * twoShowLabel;

@property (nonatomic, weak)UIButton * shareImageView;

@property (nonatomic, weak)UILabel * explationTwoLabel;

@property (nonatomic, weak)UIView * twoLineView;

@property (nonatomic, weak)UIImageView * inviteImageView;

@property (nonatomic, weak)UILabel * myInviteCardLabel;

@end

@implementation PushOutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didCancleButton) name:@"didCancleButton" object:nil];
    
    [self setupNavBar];
    [self setupUI];
}

- (void)setupNavBar{
    
    self.title = @"推广赚钱";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToAccountView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}


- (void)setupUI{
    
    
    
    UIImageView * backImage = [[UIImageView alloc] init];
    
    backImage.image = [UIImage imageNamed:@"背景"];
    
    self.backImageView = backImage;
    
    [self.view addSubview:self.backImageView];
    
    self.pushView = [[PushOutBottomView alloc] initWithFrame:CGRectMake(0, SCREENH_HEIGHT, SCREEN_WIDTH, 170 * SCREEN_WIDTH)];
    
    [self.view addSubview:self.pushView];
    
    UILabel * oneShowLabel = [[UILabel alloc] init];
    
    oneShowLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16 * SCREENH6];
    oneShowLabel.textColor = ColorWithRGB(0xffffff);
    oneShowLabel.text = @"1.邀请码邀请";
    
    self.oneShowLabel = oneShowLabel;
    
    [self.view addSubview:self.oneShowLabel];
    
    UILabel * inviteNumLabel = [[UILabel alloc] init];
    
    inviteNumLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    inviteNumLabel.textColor = ColorWithRGB(0xc8c8c8);
    inviteNumLabel.text = @"您的邀请码为：";
    
    self.inviteNumLabel = inviteNumLabel;
    
    [self.view addSubview:self.inviteNumLabel];
    
    UILabel * numberLabel = [[UILabel alloc] init];
    
    numberLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    numberLabel.textColor = ColorWithRGB(0xc8c8c8);
    numberLabel.text = @"8888";
    
    self.numberLabel = numberLabel;
    
    [self.view addSubview:self.numberLabel];
    
    UILabel * explationOneLabel = [[UILabel alloc] init];
    
    explationOneLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    explationOneLabel.textColor = ColorWithRGB(0xd23d38);
    explationOneLabel.text = @"*您的朋友在注册的时候，输入此邀请码，您就能收益。";
    
    self.explationOneLabel = explationOneLabel;
    
    [self.view addSubview:self.explationOneLabel];
    
    
    UIView * oneLineView = [UIView new];
    
    oneLineView.backgroundColor = [UIColor whiteColor];
    oneLineView.alpha = 0.1;
    
    self.oneLineView = oneLineView;
    
    [self.view addSubview:self.oneLineView];
    
    
    UILabel * twoShowLabel = [[UILabel alloc] init];
    
    twoShowLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16 * SCREENH6];
    twoShowLabel.textColor = ColorWithRGB(0xffffff);
    twoShowLabel.text = @"2.分享赚钱";
    
    self.twoShowLabel = twoShowLabel;
    
    [self.view addSubview:self.twoShowLabel];
    
    
    UIButton * shareImageView = [UIButton new];
    
//    shareImageView.image = [UIImage imageNamed:@"分享"];
    [shareImageView addTarget:self action:@selector(didShareButton) forControlEvents:UIControlEventTouchUpInside];
    [shareImageView setImage:[UIImage imageNamed:@"分享"] forState:UIControlStateNormal];
    
    self.shareImageView = shareImageView;
    
    [self.view addSubview:self.shareImageView];
    
    UILabel * explationTwoLabel = [[UILabel alloc] init];
    
    explationTwoLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    explationTwoLabel.textColor = ColorWithRGB(0xd23d38);
    explationTwoLabel.text = @"用户通过您的邀请链接，注册成功，您就能收益。";
    
    self.explationTwoLabel = explationTwoLabel;
    
    [self.view addSubview:self.explationTwoLabel];
 
    
    UIView * twoLineView = [UIView new];
    
    twoLineView.backgroundColor = [UIColor whiteColor];
    twoLineView.alpha = 0.1;
    
    self.twoLineView = twoLineView;
    
    [self.view addSubview:self.twoLineView];
    
    
    UIImageView * inviteImage = [UIImageView new];
    
    inviteImage.image = [UIImage imageNamed:@"二维码点缀"];
    
    self.inviteImageView = inviteImage;
    
    [self.view addSubview:self.inviteImageView];
    
    
    UILabel * myInviteCardLabel = [[UILabel alloc] init];
    
    myInviteCardLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    myInviteCardLabel.textColor = ColorWithRGB(0xd23d38);
    myInviteCardLabel.text = @"我的专属二维码";
    
    self.myInviteCardLabel = myInviteCardLabel;
    
    [self.view addSubview:self.myInviteCardLabel];
}

- (void)viewDidLayoutSubviews{
    
//    [self.pushView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.trailing.mas_equalTo(self.view);
//        make.centerY.mas_equalTo(self.view);
//    }];
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
    [self.oneShowLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
        make.top.mas_equalTo(self.view).offset(84 * SCREENH6);
    }];
    
    [self.inviteNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.oneShowLabel);
        make.top.mas_equalTo(self.oneShowLabel.mas_bottom).offset(10 * SCREENH6);
    }];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.inviteNumLabel.mas_trailing);
        make.centerY.mas_equalTo(self.inviteNumLabel);
    }];
    
    [self.explationOneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.inviteNumLabel);
        make.top.mas_equalTo(self.inviteNumLabel.mas_bottom).offset(10 * SCREENH6);
    }];
    
    [self.oneLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(1 * SCREENH6);
        make.top.mas_equalTo(self.view).offset(191 * SCREENH6);
    }];
    
    [self.twoShowLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.oneShowLabel);
        make.top.mas_equalTo(self.oneLineView.mas_bottom).offset(18 * SCREENH6);
    }];
    
    [self.shareImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.view).offset(- 15 * SCREENH6);
        make.width.mas_equalTo(22 * SCREENH6);
        make.height.mas_equalTo(21 * SCREENH6);
        make.top.mas_equalTo(self.oneLineView.mas_bottom).offset(10 * SCREENH6);
    }];
    
    [self.explationTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.twoShowLabel.mas_bottom).offset(10 * SCREENH6);
        make.leading.mas_equalTo(self.twoShowLabel);
    }];
    
    [self.twoLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.oneLineView.mas_bottom).offset(91 * SCREENH6);
        make.leading.trailing.height.mas_equalTo(self.oneLineView);
    }];
    
    [self.inviteImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.twoLineView.mas_bottom).offset(48 * SCREENH6);
        make.centerX.mas_equalTo(self.view);
        make.height.width.mas_equalTo(134 * SCREENH6);
    }];
    
    [self.myInviteCardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.inviteImageView.mas_bottom).offset(12 * SCREENH6);;
    }];
}


- (void)didShareButton{
    
    self.pushView.transform = CGAffineTransformTranslate(self.pushView.transform , 0, - 170 * SCREENH6);
}

- (void)didCancleButton{
    
    self.pushView.transform = CGAffineTransformIdentity;
    
}


- (void)backToAccountView{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
